export const tabCloumns = [
  {
    dataIndex: 'fx',
    key: 'fx',
    width: 60,
    slots:{title:'customTitle'},
    scopedSlots: { customRender: 'fx' },
    fixed:'left',
    isInput:false,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        },
      }
    })
  },{
    title: '物料编码',
    dataIndex: 'wlbm',
    key: 'wlbm',
    width: 150,
    fixed:'left',
    fieldType: 'Input',
    isInput:true,
    scopedSlots: { filterDropdown: 'filterDropdown',filterIcon: 'filterIcon',customRender: 'customRender' },
    onFilter: (value, record) => {
      if(record.wlbm){
        return record.wlbm
        .toString()
        .toLowerCase()
        .includes(value.toLowerCase())
      }
    },
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '核心采购件名称',
    dataIndex: 'hxcgjmc',
    key: 'hxcgjmc',
    width: 150,
    scopedSlots: { filterDropdown: 'filterDropdown',filterIcon: 'filterIcon',customRender: 'customRender' },
    fixed:'left',
    isInput:true,
    isRequire:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    }),
    onFilter: (value, record) => {
      if(record.hxcgjmc){
        return record.hxcgjmc
        .toString()
        .toLowerCase()
        .includes(value.toLowerCase())
      }
    },
  },{
    title: '推荐品牌',
    dataIndex: 'tjpp',
    key: 'tjpp',
    width: 150,
    scopedSlots: { customRender: 'tjpp' },
    isInput:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '推荐供方',
    dataIndex: 'tjgf',
    key: 'tjgf',
    width: 150,
    scopedSlots: { customRender: 'tjgf' },
    isInput:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '数量',
    dataIndex: 'sl',
    key: 'sl',
    width: 150,
    scopedSlots: { customRender: 'sl' },
    isInput:true,
    types:'number',
    isRequire:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '单位',
    dataIndex: 'dw',
    key: 'dw',
    width: 150,
    scopedSlots: { customRender: 'dw' },
    isInput:true,
    isRequire:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '技术参数及型号规格',
    dataIndex: 'jscsjxhgg',
    key: 'jscsjxhgg',
    width: 180,
    scopedSlots: { customRender: 'jscsjxhgg' },
    isInput:true,
    isRequire:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '研发附件',
    dataIndex: 'yffj',
    key: 'yffj',
    width: 150,
    scopedSlots: { customRender: 'yffj' },
    isInput:false,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '提报人',
    dataIndex: 'tbr',
    key: 'tbr',
    width: 150,
    scopedSlots: { customRender: 'tbr' },
    isInput:true,
    isRequire:true,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '操作',
    dataIndex: 'operation',
    width: 150,
    scopedSlots: { customRender: 'operation' },
    isInput:false,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title: '品类',
    dataIndex: 'pl',
    key: 'pl',
    width: 150,
    scopedSlots: { customRender: 'pl' },
    isInput:false,
    customCell:(row=>{
      return{
        style: {display: row.materIdSpan == 0 ? 'none' : undefined},
        attrs:{
          rowSpan:row.materIdSpan,
        }
      }
    })
  },{
    title:'现有供方',
    children:[{
      title: '供应商',
      dataIndex: 'gys',
      key: 'gys',
      width: 150,
      isInput:false,
    },{
      title: '物料及参数',
      dataIndex: 'wljcs',
      key: 'wljcs',
      width: 150,
      isInput:false,
    }]
  },{
    title:'主机竞品',
    children:[{
      title: '竞品供方',
      dataIndex: 'jpgf',
      key: 'jpgf',
      width: 150,
      isInput:false,
    },{
      title: '物料及参数',
      dataIndex: 'zjwljcs',
      key: 'zjwljcs',
      width: 150,
      isInput:false,
    }]
  },{
    title:'市场其他主机产品',
    children:[{
      title: '其他产品供方',
      dataIndex: 'qtcpgf',
      key: 'qtcpgf',
      width: 150,
      isInput:false,
    },{
      title: '物料及参数',
      dataIndex: 'scwljcs',
      key: 'scwljcs',
      width: 150,
      isInput:false,
    }]
  },{
    title: '市场新技术方案推荐',
    dataIndex: 'scxjstjfa',
    key: 'scxjstjfa',
    width: 150,
    isInput:false,
  },{
    title: '商务附件',
    dataIndex: 'swfj',
    key: 'swfj',
    width: 150,
    isInput:false,
  },{
    title: '状态',
    dataIndex: 'fj',
    key: 'fj',
    width: 150,
    isInput:false,
  }
]

export function mergeCell(data, keys) {
  let tempValue = "";
  for (let kIndex = 0; kIndex < keys.length; kIndex++) {
    let key = keys[kIndex];
    let spanKey = key + "Span";
    for (let i = 0; i < data.length; ) {
      var rowSpan = 0;
      if (tempValue !== data[i][key]) {
        tempValue = data[i][key] || "";
        if (tempValue) {
          for (let j = i; j < data.length; j++) {
            const item = data[j];
            if (item[key] === tempValue) {
              rowSpan += 1;
            } else {
              break;
            }
          }
        } else {
          rowSpan += 1;
        }
      }
      data[i][spanKey] = rowSpan;
      for (let j = i + 1; j < i + rowSpan && j < data.length; j++) {
        data[j][spanKey] = 0;
      }
      i += rowSpan;
    }
  }
  return data;
}